package com.ybu.oodd.mapper;

import com.ybu.oodd.pojo.Job;
import com.ybu.oodd.pojo.QueryParams;
import com.ybu.oodd.pojo.Status;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface JobMapper {
    /*
    * 根据userId和jobId 查询 statusId
    * */
    @Select("select status_id from status where user_id = #{userId} and job_id = #{jobId}")
    Integer getStatusId(Status status);

    /*
    * 根据userId和jobId更新statusId
    * */
    @Update("update status set status_id = #{statusId} where user_id = #{userId} and job_id = #{jobId}")
    void updateStatus(Status status);

    /*
     * 根据userId和jobId新增statusId
     * */
    @Insert("insert into status(status_id,user_id,job_id) values(#{statusId},#{userId},#{jobId})")
    void insertStatus(Status status);

    /*
     * 查询关键字
     * */
    List<Map<Integer, String>> getKeywordByTypeIsLiked(String type,String likes,Boolean isLiked);

    /*
     * 条件分页查询岗位 status其他
     * */
    List<Job> getJobs(QueryParams sp);

    /*
     * 条件分页查询岗位 status==null
     * */
    List<Job> getJobsNull(QueryParams sp);

    /*
     * 条件分页查询岗位 status==20
     * */
    List<Job> getJobsES(QueryParams sp);
}
